﻿using UnityEngine;

public class RunState : StateTemplate<PlayerController>
{

    Vector2 movement;
    public RunState(int id, PlayerController p) : base(id, p)
    {

    }
    public override void OnEnter(params object[] args)
    {
       
        owner.anim.SetBool("isRun", true);
        owner.anim.SetBool("isIdle", false);
        base.OnEnter(args);
    }
    public override void OnStay(params object[] args)
    {
        owner.anim.SetBool("isIdle", false);
        owner.anim.SetBool("isRun", true);
        movement.x = Input.GetAxis("Horizontal");
        base.OnStay(args);
    }
    public override void OnExit(params object[] args)
    {
        owner.anim.SetBool("isRun", false);
        base.OnExit(args);
    }

    public override void OnFixedStay(params object[] args)
    {
        
        owner.rb.MovePosition(owner.rb.position + movement * owner.speed * Time.fixedDeltaTime);
    }

}

